package com.iot.controller;

import com.iot.model.dto.DeviceDto;
import com.iot.model.query.DeviceQuery;
import com.iot.commons.ResponseResult;
import com.iot.service.DeviceService;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.bind.annotation.RequestMapping;

/**
 * 
 * @author: dh
 * @date: 2024-04-20 23:39:54
 */
@RestController
@RequestMapping("/device")
@RequiredArgsConstructor
public class DeviceController {

    private final DeviceService deviceService;

    /**
     * 分页条件搜索实现
     * @param device
     * @return resultList
     */
    @PostMapping(value = "/getList")
    public ResponseResult getList(@RequestBody DeviceQuery device) {
        return  deviceService.getList(device);
    }

    /**
     * 修改
     * @param device
     * @return
     */
    @PostMapping(value = "/edit")
    public ResponseResult edit(@RequestBody DeviceDto device) {
        return deviceService.edit(device);
    }

    /**
     * 新增
     * @param device
     * @return
     */
    @PostMapping(value = "/bind")
    public ResponseResult bind(@RequestBody DeviceDto device) {
        return deviceService.bind(device);
    }


    /**
     * 新增
     * @return
     */
    @PostMapping(value = "/unbind")
    public ResponseResult unbind() {
        return deviceService.unbind();
    }

    /**
     * 详情
     * @param device
     * @return
     */
    @PostMapping(value = "/getById")
    public ResponseResult getById(@RequestBody DeviceQuery device) {
        return deviceService.getById(device);
    }
}
